﻿//===========================[ 7 / 6 / 2011 LVI ]=============================
//				Copyright c Vitaly Lyaschenko <SkyChameleon@gmail.com>
//								Source file
// Purpose: 
//
//=============================================================================
#include "cFPSCounter.h"

cFPSCounter::cFPSCounter(void) :
	frameInterval(0.0f),
	internalFPS(0.0f),
	tickCounter(0.0f),
	elapsedTime (0.0f),
	frameStart(0.0f),
	fps(0.0f)
{	}

const float cFPSCounter::getFrameInterval() const 
{ 
	return frameInterval; 
}

const float cFPSCounter::getElapsedTime() const 
{ 
	return elapsedTime;   
}

const float cFPSCounter::getFPS() const 
{ 
	return fps;           
}

void cFPSCounter::FrameStart()
{

	frameStart = cTimer::getCurrentTime();
}

void cFPSCounter::FrameEnd()
{
	if( frameStart )
	{
		cTimer::update();
		frameInterval = cTimer::getFrameTime();
		tickCounter  += frameInterval;
		elapsedTime  += frameInterval;
		internalFPS++;

		if( tickCounter >= 1.0f )
		{
			fps          = internalFPS / tickCounter;
			internalFPS  = 0.0f;
			tickCounter  = 0.0f;
		}
	}
}
